{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}
{{> common/auto_generated_py}}
{{^program:auto_migrate?}}
{{^program:inplace_migrate?}}

{{> types/cimport_std }}

from thrift.python.exceptions cimport cTException
cimport thrift.py3.exceptions
cimport thrift.py3.types
from thrift.python.std_libcpp cimport string_view as __cstring_view
from thrift.py3.types cimport (
    bstring,
    bytes_to_string,
    field_ref as __field_ref,
    optional_field_ref as __optional_field_ref,
    required_field_ref as __required_field_ref,
    terse_field_ref as __terse_field_ref,
    StructFieldsSetter as __StructFieldsSetter
)
from thrift.python.protocol cimport Protocol as __Protocol
from folly.optional cimport cOptional as __cOptional

{{#program:includeNamespaces}}
{{#hasTypes?}}
cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types
cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}cbindings as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}cbindings
{{/hasTypes?}}
{{/program:includeNamespaces}}

cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as {{> types/current_module_types}}
cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.cbindings as {{> types/current_module_cbindings}}


{{#program:filtered_structs}}
{{^struct:union?}}

ctypedef void (*__{{struct:name}}_FieldsSetterFunc)(__{{struct:name}}_FieldsSetter, object) except *

cdef class __{{struct:name}}_FieldsSetter(__StructFieldsSetter):
    cdef {{> types/current_module_cbindings}}.{{> types/c_struct }}* _struct_cpp_obj
    cdef cumap[__cstring_view, __{{struct:name}}_FieldsSetterFunc] _setters

    @staticmethod
    cdef __{{struct:name}}_FieldsSetter _fbthrift_create({{> types/current_module_cbindings}}.{{> types/c_struct }}* struct_cpp_obj)
    {{#struct:py3_fields}}
    {{#field:type}}
    cdef void _set_field_{{field:index}}(self, _fbthrift_value) except *
    {{/field:type}}
    {{/struct:py3_fields}}

{{/struct:union?}}
{{/program:filtered_structs}}
{{/program:inplace_migrate?}}
{{/program:auto_migrate?}}
